﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class DetalleAgrupacion extends GeneralEntity
{
	static  String strTableName="DetalleAgrupacion";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		DetalleAgrupacion.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public DetalleAgrupacion detalleagrupacionOriginal;
	
	public DetalleAgrupacion getDetalleAgrupacionOriginal()
	{
		return detalleagrupacionOriginal;
	}
	
	public  void  setDetalleAgrupacionOriginal(DetalleAgrupacion detalleagrupacion)
	{
		try
		{
			detalleagrupacionOriginal=detalleagrupacion;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	Agrupacion relationship_agrupacion;
	CaracteristicaControlAjax relationship_caracteristicacontrolajax;
	 
	
	public Agrupacion getRelationship_Agrupacion()
	{
		return relationship_agrupacion;
	}

	public CaracteristicaControlAjax getRelationship_CaracteristicaControlAjax()
	{
		return relationship_caracteristicacontrolajax;
	}

	
	
	public  void  setRelationship_Agrupacion(Agrupacion agrupacion)
	{
		try
		{
			relationship_agrupacion=agrupacion;
		}
		catch(Exception ex)
		{
			;
		}
	}


	public  void  setRelationship_CaracteristicaControlAjax(CaracteristicaControlAjax caracteristicacontrolajax)
	{
		try
		{
			relationship_caracteristicacontrolajax=caracteristicacontrolajax;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	
	
	
	
	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.DetalleAgrupacion set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDAGRUPACION=?,IDCARACTERISTICACONTROLAJAX=?,DETALLECONFIGURACION=?,DETALLEDESCRIPCION=?";
	private static String QueryUpdate="update aulavirtualme_dbo.DetalleAgrupacion set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDAGRUPACION=?,IDCARACTERISTICACONTROLAJAX=?,DETALLECONFIGURACION=?,DETALLEDESCRIPCION=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.DetalleAgrupacion where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.DetalleAgrupacion.id,aulavirtualme_dbo.DetalleAgrupacion.isActive,aulavirtualme_dbo.DetalleAgrupacion.isExpired,aulavirtualme_dbo.DetalleAgrupacion.versionRow,aulavirtualme_dbo.DetalleAgrupacion.IDAGRUPACION,aulavirtualme_dbo.DetalleAgrupacion.IDCARACTERISTICACONTROLAJAX,aulavirtualme_dbo.DetalleAgrupacion.DETALLECONFIGURACION,aulavirtualme_dbo.DetalleAgrupacion.DETALLEDESCRIPCION from aulavirtualme_dbo.DetalleAgrupacion";
	 
	Long field_bigIdAgrupacion;
	Long field_bigIdCaracteristicaControlAjax;
	String field_strDetalleconfiguracion;
	String field_strDetalledescripcion;
				
	public DetalleAgrupacion ()
    {
		super();		
 		field_bigIdAgrupacion=-1L;
 		field_bigIdCaracteristicaControlAjax=-1L;
 		field_strDetalleconfiguracion=null;
 		field_strDetalledescripcion=null;
		
		
		relationship_agrupacion=new Agrupacion();
		relationship_caracteristicacontrolajax=new CaracteristicaControlAjax();
		
		
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		DetalleAgrupacion.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.DetalleAgrupacion";
    }
	
    
	public static String getColumnNameidAgrupacion()
	{
		return "idAgrupacion";
	}
    
	public static String getColumnNameidCaracteristicaControlAjax()
	{
		return "idCaracteristicaControlAjax";
	}
    
	public static String getColumnNameDetalleConfiguracion()
	{
		return "DetalleConfiguracion";
	}
    
	public static String getColumnNameDetalleDescripcion()
	{
		return "DetalleDescripcion";
	}
     
    
	public Long getField_bigIdAgrupacion()
	{
		return field_bigIdAgrupacion;
	}
    
	public Long getField_bigIdCaracteristicaControlAjax()
	{
		return field_bigIdCaracteristicaControlAjax;
	}
    
	public String getField_strDetalleconfiguracion()
	{
		return field_strDetalleconfiguracion;
	}
    
	public String getField_strDetalledescripcion()
	{
		return field_strDetalledescripcion;
	}
	
    
	public void setField_bigIdAgrupacion(Long newField_bigIdAgrupacion)throws Exception
	{
		try
		{
			if(this.field_bigIdAgrupacion!=newField_bigIdAgrupacion)
			{
				if(newField_bigIdAgrupacion==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+DetalleAgrupacion.getColumnNameidAgrupacion());
				}

				this.field_bigIdAgrupacion=newField_bigIdAgrupacion;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_bigIdCaracteristicaControlAjax(Long newField_bigIdCaracteristicaControlAjax)throws Exception
	{
		try
		{
			if(this.field_bigIdCaracteristicaControlAjax!=newField_bigIdCaracteristicaControlAjax)
			{
				if(newField_bigIdCaracteristicaControlAjax==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+DetalleAgrupacion.getColumnNameidCaracteristicaControlAjax());
				}

				this.field_bigIdCaracteristicaControlAjax=newField_bigIdCaracteristicaControlAjax;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strDetalleconfiguracion(String newField_strDetalleconfiguracion)
	{
		if(this.field_strDetalleconfiguracion!=newField_strDetalleconfiguracion)
		{
			this.field_strDetalleconfiguracion=newField_strDetalleconfiguracion;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strDetalledescripcion(String newField_strDetalledescripcion)
	{
		if(this.field_strDetalledescripcion!=newField_strDetalledescripcion)
		{
			this.field_strDetalledescripcion=newField_strDetalledescripcion;
			this.setIsChanged(true);
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdAgrupacion=new ParameterValue<Long>();
					parameterMaintenanceValueIdAgrupacion.setValue(this.getField_bigIdAgrupacion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdAgrupacion);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdCaracteristicaControlAjax=new ParameterValue<Long>();
					parameterMaintenanceValueIdCaracteristicaControlAjax.setValue(this.getField_bigIdCaracteristicaControlAjax());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdCaracteristicaControlAjax);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueDetalleconfiguracion=new ParameterValue<String>();
					parameterMaintenanceValueDetalleconfiguracion.setValue(this.getField_strDetalleconfiguracion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueDetalleconfiguracion);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueDetalledescripcion=new ParameterValue<String>();
					parameterMaintenanceValueDetalledescripcion.setValue(this.getField_strDetalledescripcion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueDetalledescripcion);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(7);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(8);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
